<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>

<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<!--<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />-->
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />
<style type="text/css">
table.stats{
	text-align: center;
	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif ;
	font-weight: normal;
	font-size: 11px;
	color: #900000;
	width: 1000px;
	background-color: red;
	border: 0px;
	border-collapse: collapse;
	border-spacing: 0px;}

table.stats td{
	background-color: #900000;
	color: #fff;
	padding: 4px;
	/*text-align: center;*/
	border: 1px #FFABAB solid;
	font-weight: bold;}

table.stats td.hed{
	background-color: #E73737;
	color: #fff;
	padding: 4px;
	/*text-align: center;*/
	border-bottom: 2px #FFABAB solid;
	font-size: 12px;
	font-weight: bold;}
</style>

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
	$param_exp=explode("#",$paramid);
	$value = array(
		'nama_sekolah'			=> "",
		'id_sekolah'			=> "",
		'tahun_ajaran'			=> $tahunajaran->row()->TAHUN_AJARAN,
		'tingkat'				=> "",
		'kelas'					=> "",
		'semester'				=> "",
		'pelajaran'				=> "",
		'nilairaport'			=> "",
		'keterangan'			=> "",
		
		'legend'				=> "Form Input Nilai Raport",
		'info'					=> "Form Input Nilai Raport",
		'act_form'				=> "nilai_raport/input_nilairaport/".$param_exp[0]."/".$param_exp[1]."/".$param_exp[2]."/".$param_exp[3]."/".$param_exp[4]."/".$param_exp[5]
	);
	foreach($rs_nilaisiswa->result() as $row_nilai){
		$nilai[$row_nilai->NISN][$row_nilai->KODE_UJIAN] = $row_nilai->NILAI;
	}
	
	//Setting Value pada form Jika melakukan prosedur Edit terhadap data tertentu.
	if($status == "edit"){
		foreach($rs_nilairaport->result() as $row){
			$value['id_sekolah'] = $row->ID_SEKOLAH;
			$value['tahun_ajaran'] = $row->TAHUN_AJARAN;
			$value['tingkat'] = $row->ID_TINGKAT;
			$value['kelas'] = $row->ID_KELAS;
			$value['semester'] = $row->ID_SEMESTER;
			$value['pelajaran'] = $row->KODE_MATA_PELAJARAN;
			$keterangan[$row->NISN] = $row->KETERANGAN;
			$nilairaport[$row->NISN] = $row->NILAI;
		}
		$value['legend'] = "Form Input Nilai Raport";
		$value['info'] = "Form Input Nilai Raport";
		$value['act_form'] = "nilai_raport/edit_nilairaport/".$param_exp[0]."/".$param_exp[1]."/".$param_exp[2]."/".$param_exp[3]."/".$param_exp[4]."/".$param_exp[5];
	
	}//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_rpp"'); ?>
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url('nilai_raport/index/'.$param_exp[0].'/'.$param_exp[1].'/'.$param_exp[2].'/'.$param_exp[3].'/'.$param_exp[4].'/'.$param_exp[5]),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke daftar Nilai Siswa','Menampilkan halaman Daftar Nilai Siswa'); ?>
	
	</div>
	<?php if (!empty($err_msg)): ?>
		<div class="ret_error">
			<?php echo $err_msg; ?>
		</div>
	<?php endif; ?>
 <!-- Konten -------------------------------------------------------------------------->
 <div id="contentform">
	<ul>
		<?php if($this->session->userdata('roleid')=='0'){ //diknas ?>
		<li>
			<label class="desc">Nama Sekolah *</label>
			 <div>
                <? 
                //list sekolah
				$options_sekolah[''] = "-- Pilih Sekolah --";
				foreach($sekolah->result() as $row_sekolah){
					$options_sekolah[$row_sekolah->ID_SEKOLAH] = $row_sekolah->NAMA_SEKOLAH; 
				}
				echo form_dropdown('nama_sekolah',$options_sekolah,$value['id_sekolah'],'class="field select"');	
                ?>
            </div>
            <p class="instruct">
                Pilih Sekolah Pada Kolom ini, jika tidak ada dalam daftar maka inputkan pada Data Sekolah terlebih dahulu.			
            </p>
		</li>
		<?php echo form_error('nama_sekolah'); ?>
		<?}?>
		
		<li>
			<label class="desc">Tahun Ajaran *</label>
			 <div>
				<input class="field text" disabled type="text" maxlength="12" size="12" name="tahun_ajaran"  style="background:#e0e2e3" value="<?php echo $tahunajaran->row()->TAHUN_AJARAN?>"/> 
				<input type="hidden" name="tahun_ajaran" id="tahun_ajaran" value="<?php echo $tahunajaran->row()->ID_TA ;?>">
			</div>
		</li>
		
		<li>
			<label class="desc">Tingkat *</label>
			 <div>
                <? 
                //list tingkat
				if($status=='new') $val_tingkat = $this->session->userdata('sess_nilai_tingkat');
				else $val_tingkat = $value['tingkat'];
				$options_tingkat[''] = "-- Pilih Tingkat Pendidikan --";
				foreach($r_tingkat->result() as $row_tingkat){
					$options_tingkat[$row_tingkat->ID_TINGKAT] = $row_tingkat->TINGKAT; 
				}
				echo form_dropdown('tingkat',$options_tingkat,$val_tingkat,'class="field select" style="background:#e0e2e3" disabled');
				echo '<input type="hidden" name="tingkat" id="tingkat" value="'.$val_tingkat.'">';				
                ?>
            </div>
		</li>
		
		<li>
			<label class="desc">Kelas *</label>
			 <div>
                <? 
                //list kelas
				if($status=='new') $val_kelas = $this->session->userdata('sess_nilai_kelas');
				else $val_kelas = $value['kelas'];
				$options_kelas[''] = "-- Pilih Kelas --";
				foreach($r_kelas->result() as $row_kelas){
					$options_kelas[$row_kelas->ID_KELAS] = $row_kelas->KELAS; 
				}
				echo form_dropdown('kelas',$options_kelas,$val_kelas,'class="field select" style="background:#e0e2e3" disabled');
				echo '<input type="hidden" name="kelas" id="kelas" value="'.$val_kelas.'">';					
                ?>
            </div>
		</li>
		
		<li>
			<label class="desc">Semester *</label>
			 <div>
                <? 
                //list semester
				if($status=='new') $val_semester = $this->session->userdata('sess_nilai_semester');
				else $val_semester = $value['semester'];
				$options_semester[''] = "-- Pilih Semester --";
				foreach($r_semester->result() as $row_semester){
					$options_semester[$row_semester->ID_SMT] = $row_semester->SEMESTER; 
				}
				echo form_dropdown('semester',$options_semester,$val_semester,'class="field select" style="background:#e0e2e3" disabled');	
				echo '<input type="hidden" name="semester" id="semester" value="'.$val_semester.'">';		
                ?>
            </div>
		</li>
		
		<li>
			<label class="desc">Pelajaran *</label>
			 <div>
                <? 
                //list pelajaran
				$options_pelajaran[''] = "-- Pilih Pelajaran --";
				foreach($r_pelajaran->result() as $row_pelajaran){
					$options_pelajaran[$row_pelajaran->KODE_MATA_PELAJARAN] = $row_pelajaran->NAMA_MATA_PELAJARAN; 
				}
				echo form_dropdown('pelajaran',$options_pelajaran,$r_pelajaran->row()->KODE_MATA_PELAJARAN,'class="field select" style="background:#e0e2e3" disabled');	
				echo '<input type="hidden" name="pelajaran" id="pelajaran" value="'.$r_pelajaran->row()->KODE_MATA_PELAJARAN.'">';		
                ?>
            </div>
		</li>
		<?php echo form_error('pelajaran'); ?>
		
		<li>
			<label class="desc">Daftar Siswa</label>Skala Nilai antara 1 - 100
			<table class="stats" cellspacing="0">
				<tr><td width="50" align="center">No.</td>
					<td width="100" nowrap align="center">NISN</td>
					<td width="250" nowrap align="center">Nama Lengkap</td>
					<? foreach($jml_kolom->result() as $row_col){?>
						<td width="50" nowrap align="center"><?php echo $row_col->NAMA_UJIAN.' ('.$row_col->PROSENTASE.'%)' ?></td>
					<?}?>
					<td width="70" nowrap align="center">Rata2 Nilai</td>
					<td width="50" nowrap align="center">Nilai Raport</td>
					<td width="250" nowrap align="center">Keterangan</td>
				</tr>
				<?$i=1; foreach($r_daftarsiswa->result() as $row){?>
				<tr>
					<td class="hed" ><?php echo $i++;?></td>
					<td class="hed"><?php echo $row->NISN; ?></td>
					<td class="hed" align="left"><?php echo $row->NAMA_LENGKAP; ?></td>
					<? $rata=0;foreach($jml_kolom->result() as $row_col){
						if(!empty($nilai[$row->NISN][$row_col->KODE_UJIAN])){
							$rata += $nilai[$row->NISN][$row_col->KODE_UJIAN]*($row_col->PROSENTASE/100);
						}
						 
					?>
						<td class="hed">
							<?php if(!empty($nilai[$row->NISN][$row_col->KODE_UJIAN])){ echo $nilai[$row->NISN][$row_col->KODE_UJIAN];} else echo '';?>
							<!--<input class="field text" type="text" maxlength="6" size="6" name="nilai_<?php echo $row->NISN?>_<?php echo $row_col->KODE_UJIAN?>" value="<?php echo $status=='edit'?$nilai[$row->NISN][$row_col->KODE_UJIAN]:''?>"/>-->
						</td>
					<?}?>
					<td class="hed"><?php echo $rata;?></td>
					<td class="hed"><input class="field text" type="text" maxlength="6" size="6" name="nilairaport_<?php echo $row->NISN?>" value="<?php if($status=='edit' and !empty($nilairaport[$row->NISN])){ echo $nilairaport[$row->NISN];} else echo '';?>"/></td>
					<td class="hed"><input class="field text" type="text" maxlength="255" size="70" name="keterangan_<?php echo $row->NISN?>" value="<?php if($status=='edit' and !empty($keterangan[$row->NISN])){ echo $keterangan[$row->NISN]; }else echo '';?>"/></td>
				</tr>
				<?}?>
			</table>
		</li>
		
		
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Simpan" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>	
<?= form_close(); ?>
</form>
</div><!--container-->